import request from '@/utils/request'

export const getRouters = () => {
    return request({
        url: '/system/menu/getRouters',
        method: 'get'
    })
}

// 查询菜单列表
export const listMenu=(query?:any)=> {
    return request({
        url: '/system/menu/list',
        method: 'get',
        params: query
    })
}

// 查询菜单详细
export const getMenu=(menuId:string) =>{
    return request({
        url: '/system/menu/' + menuId,
        method: 'get'
    })
}

// 查询菜单下拉树结构
export const treeselect=()=> {
    return request({
        url: '/system/menu/treeselect',
        method: 'get'
    })
}



// 新增菜单
export const addMenu=(data:any) =>{
    return request({
        url: '/system/menu',
        method: 'post',
        data: data
    })
}

// 修改菜单
export const updateMenu=(data:any) =>{
    return request({
        url: '/system/menu',
        method: 'put',
        data: data
    })
}

// 删除菜单
export const delMenu=(menuId:[]|string)=> {
    return request({
        url: '/system/menu/' + menuId,
        method: 'delete'
    })
}


/**
 * 根据角色ID查询菜单下拉树结构
 *
 * @param {string} roleId 角色ID
 * @returns
 */
export const roleMenuTreeSelect = (roleId: string) => {
    return  request({
        url: '/system/menu/rolemenutreeselect/' + roleId,
        method: "get",
    });
};
